<template>
	<Modal v-model="modal" title="详情">
		<Form ref="formValidate" :label-width="100">
			<FormItem label='审核状态' prop='isAudit'>
				<Radio-group v-model="isAudit">
					<Radio :label="1">同意</Radio>
					<Radio :label="2">拒绝</Radio>
				</Radio-group>
			</FormItem>
			<FormItem label='拒绝原因' prop='refuseReason' v-if="isShow">
				<Input v-model="refuseReason" type="textarea" />
			</FormItem>
		</Form>
		<div slot="footer">
			<Button type="primary" @click="submit" :loading="loadingBtn">
				<span v-if="!loadingBtn">确定</span>
				<span v-else>请稍候...</span>
			</Button>
			<Button @click="cancel">取消</Button>

		</div>
	</Modal>
</template>

<script>
	import {
		formatDate
	} from '../utils/time.js'
	export default {
		components: {},
		props: {
			type:Number
		},
		data() {
			return {
				modal: false,
				isEdit: false,
				loadingBtn: false,
				isShow: false,
				isAudit: 1,
				refuseReason: '',
				userId: '',
				roleId: '',
			}
		},
		  watch: {
          'isAudit': function(newVal){
             if(newVal==2){
				 this.isShow=true
			 }else{
				  this.isShow=false
			 }
          }
      },
		methods: {

			show(res) {
				this.$nextTick(() => {
					this.modal = true
					this.roleId = this.type
					this.userId = res.row.userId
				})

			},
			//取消
			cancel() {
				this.modal = false
			},
			//审核通过
			submit() {
				let data = {
					isAudit: this.isAudit,
					refuseReason: this.refuseReason,
					userId: this.userId,
					roleId: this.roleId
				}
				this.$http.post('/userrole/update', data).then(res => {
					if (res.status == 200) {
						if (res.data.code == 200) {
							this.$Message.success('审核成功')
							this.modal = false
							this.$emit('table')
						}

					}
				})

			},
			modalChange(state) {
				if (state) {

				} else {
					this.$refs.formValidate.resetFields()
				}
			}
		}
	}
</script>

<style>
</style>
